Submitted By:            Fernando de Oliveira <famobr at yahoo dot com dot br>
Date:                    2015-11-19
Initial Package Version: 2.0.0
Upstream Status:         not submitted
Origin:                  Self
Description:             Fix build against lua-5.3.1

diff -Naur wireshark-2.0.0.orig/configure wireshark-2.0.0/configure
--- wireshark-2.0.0.orig/configure	2015-11-18 19:21:26.000000000 -0300
+++ wireshark-2.0.0/configure	2015-11-19 13:21:33.119407232 -0300
@@ -37595,7 +37595,7 @@
 		# We use a for loop instead of giving all the package names to
 		# PKG_CHECK_MODULES because doing the latter doesn't appear to
 		# work reliably (some package names are not searched for).
-		for pkg in "lua < 5.3" lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
+		for pkg in  lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua5.0 lua-5.0 lua50
 		do
 
 pkg_failed=no
@@ -37699,7 +37699,7 @@
 				break
 			fi
 
-			for ver in 5.2 52 5.1 51 5.0 50
+			for ver in 5.3 53 5.2 52 5.1 51 5.0 50
 			do
 				if test -r "$dir/include/lua$ver/lua.h"
 				then
@@ -37723,13 +37723,6 @@
 $as_echo_n "checking the Lua version... " >&6; }
 			lua_ver=`$AWK '/LUA_VERSION_NUM/ { print \$NF; }' \$header_dir/lua.h | sed 's/0/./'`
 
-			if test "x$lua_ver" = "x5.3"
-			then
-				# Wireshark doesn't compile with Lua 5.3 today
-				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lua_ver - disabling Lua support" >&5
-$as_echo "$lua_ver - disabling Lua support" >&6; }
-				have_lua=no
-			else
 				{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lua_ver" >&5
 $as_echo "$lua_ver" >&6; }
 
@@ -37754,7 +37747,6 @@
 
 done
 
-			fi
 
 			if test "x$have_lua" = "x"
 			then
diff -Naur wireshark-2.0.0.orig/epan/wslua/lua_bitop.c wireshark-2.0.0/epan/wslua/lua_bitop.c
--- wireshark-2.0.0.orig/epan/wslua/lua_bitop.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/lua_bitop.c	2015-11-19 13:21:33.120407210 -0300
@@ -48,7 +48,7 @@
 
 typedef union {
   lua_Number n;
-#ifdef LUA_NUMBER_DOUBLE
+#ifdef LUA_REAL_DOUBLE
   uint64_t b;
 #else
   UBits b;
@@ -65,21 +65,21 @@
 #else
   bn.n = luaL_checknumber(L, idx);
 #endif
-#if defined(LUA_NUMBER_DOUBLE)
+#if defined(LUA_REAL_DOUBLE)
   bn.n += 6755399441055744.0;  /* 2^52+2^51 */
 #ifdef SWAPPED_DOUBLE
   b = (UBits)(bn.b >> 32);
 #else
   b = (UBits)bn.b;
 #endif
-#elif defined(LUA_NUMBER_INT) || defined(LUA_NUMBER_LONG) || \
-      defined(LUA_NUMBER_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
+#elif defined(LUA_INTEGER) || defined(LUA_INT_LONG) || \
+      defined(LUA_INT_LONGLONG) || defined(LUA_NUMBER_LONG_LONG) || \
       defined(LUA_NUMBER_LLONG)
   if (sizeof(UBits) == sizeof(lua_Number))
     b = bn.b;
   else
     b = (UBits)(SBits)bn.n;
-#elif defined(LUA_NUMBER_FLOAT)
+#elif defined(LUA_REAL_FLOAT)
 #error "A 'float' lua_Number type is incompatible with this library"
 #else
 #error "Unknown number type, check LUA_NUMBER_* in luaconf.h"
@@ -169,7 +169,7 @@
   b = barg(L, -1);
   if (b != (UBits)1437217655L || BAD_SAR) {  /* Perform a simple self-test. */
     const char *msg = "compiled with incompatible luaconf.h";
-#ifdef LUA_NUMBER_DOUBLE
+#ifdef LUA_REAL_DOUBLE
 #ifdef _WIN32
     if (b == (UBits)1610612736L)
       msg = "use D3DCREATE_FPU_PRESERVE with DirectX";
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_byte_array.c wireshark-2.0.0/epan/wslua/wslua_byte_array.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_byte_array.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_byte_array.c	2015-11-19 13:22:27.961200046 -0300
@@ -285,7 +285,7 @@
 #define WSLUA_OPTARG_ByteArray_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
 #define WSLUA_OPTARG_ByteArray_raw_LENGTH 3 /* The length of the segment to get (default=all). */
     ByteArray ba = checkByteArray(L,1);
-    guint offset = (guint) luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_OFFSET,0);
+    guint offset = (guint) (int)luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_OFFSET,0);
     int len;
 
     if (!ba) return 0;
@@ -294,7 +294,7 @@
         return 0;
     }
 
-    len = (int) luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_LENGTH, ba->len - offset);
+    len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_ByteArray_raw_LENGTH, ba->len - offset);
     if ((len < 0) || ((guint)len > (ba->len - offset)))
         len = ba->len - offset;
 
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_file.c wireshark-2.0.0/epan/wslua/wslua_file.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_file.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_file.c	2015-11-19 13:21:33.121407188 -0300
@@ -337,7 +337,7 @@
     static const char *const modenames[] = {"set", "cur", "end", NULL};
     File f = checkFile(L,1);
     int op = luaL_checkoption(L, 2, "cur", modenames);
-    gint64 offset = (gint64) luaL_optlong(L, 3, 0);
+    gint64 offset = (gint64) (long)luaL_optinteger(L, 3, 0);
     int err = WTAP_ERR_INTERNAL;
 
 
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua.h wireshark-2.0.0/epan/wslua/wslua.h
--- wireshark-2.0.0.orig/epan/wslua/wslua.h	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua.h	2015-11-19 13:22:27.967199914 -0300
@@ -84,10 +84,10 @@
 #define wslua_checkguint32(L,i) (guint32)         ( luaL_checknumber(L,i) )
 #define wslua_checkguint64(L,i) (guint64)         ( luaL_checknumber(L,i) )
 
-#define wslua_optgint(L,i,d)    (gint)            ( luaL_optinteger(L,i,d) )
+#define wslua_optgint(L,i,d)    (gint)            ( (int)luaL_optinteger(L,i,d) )
 #define wslua_optgint32(L,i,d)  (gint32)          ( luaL_optnumber(L,i,d) )
 #define wslua_optgint64(L,i,d)  (gint64)          ( luaL_optnumber(L,i,d) )
-#define wslua_optguint(L,i,d)   (guint)           ( luaL_optinteger(L,i,d) )
+#define wslua_optguint(L,i,d)   (guint)           ( (int)luaL_optinteger(L,i,d) )
 #define wslua_optguint32(L,i,d) (guint32)         ( luaL_optnumber(L,i,d) )
 #define wslua_optguint64(L,i,d) (guint64)         ( luaL_optnumber(L,i,d) )
 
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_int64.c wireshark-2.0.0/epan/wslua/wslua_int64.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_int64.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_int64.c	2015-11-19 13:21:33.123407144 -0300
@@ -276,7 +276,7 @@
 #define WSLUA_OPTARG_Int64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
                                              negative means uppercase (default=16). */
     gint64 b = getInt64(L,1);
-    lua_Integer n = luaL_optinteger(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16);
+    lua_Integer n = (int)luaL_optinteger(L, WSLUA_OPTARG_Int64_new_NUMBYTES, 16);
     const gchar *hexdigits = "0123456789abcdef";
     gchar buf[16];
     lua_Integer i;
@@ -838,7 +838,7 @@
 #define WSLUA_OPTARG_UInt64_new_NUMBYTES 2 /* The number of hex-chars/nibbles to generate,
                                               negative means uppercase (default=16). */
     guint64 b = getUInt64(L,1);
-    lua_Integer n = luaL_optinteger(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16);
+    lua_Integer n = (int)luaL_optinteger(L, WSLUA_OPTARG_UInt64_new_NUMBYTES, 16);
     const gchar *hexdigits = "0123456789abcdef";
     gchar buf[16];
     lua_Integer i;
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_internals.c wireshark-2.0.0/epan/wslua/wslua_internals.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_internals.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_internals.c	2015-11-19 13:22:27.964199980 -0300
@@ -103,7 +103,7 @@
     return val;
 }
 
-/* like luaL_optint, except converts/handles Lua booleans as well */
+/* like luaL_optinteger, except converts/handles Lua booleans as well */
 WSLUA_API int wslua_optboolint(lua_State* L, int n, int def) {
     int val = 0;
 
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_listener.c wireshark-2.0.0/epan/wslua/wslua_listener.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_listener.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_listener.c	2015-11-19 13:21:33.124407122 -0300
@@ -107,7 +107,7 @@
 
     switch ( lua_pcall(tap->L,3,1,1) ) {
         case 0:
-            retval = luaL_optinteger(tap->L,-1,1) == 0 ? FALSE : TRUE;
+            retval = (int)luaL_optinteger(tap->L,-1,1) == 0 ? FALSE : TRUE;
             break;
         case LUA_ERRRUN:
             break;
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_nstime.c wireshark-2.0.0/epan/wslua/wslua_nstime.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_nstime.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_nstime.c	2015-11-19 13:21:33.124407122 -0300
@@ -46,8 +46,8 @@
 
     if (!nstime) return 0;
 
-    nstime->secs = (time_t) luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_SECONDS,0);
-    nstime->nsecs = (int) luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_NSECONDS,0);
+    nstime->secs = (time_t) (int)luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_SECONDS,0);
+    nstime->nsecs = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_NSTime_new_NSECONDS,0);
 
     pushNSTime(L,nstime);
 
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_struct.c wireshark-2.0.0/epan/wslua/wslua_struct.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_struct.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_struct.c	2015-11-19 13:21:33.126407078 -0300
@@ -462,7 +462,7 @@
   const char *fmt = wslua_checkstring_only(L, WSLUA_ARG_Struct_unpack_FORMAT);
   size_t ld;
   const char *data = wslua_checklstring_only(L, WSLUA_ARG_Struct_unpack_STRUCT, &ld);
-  size_t pos = luaL_optinteger(L, WSLUA_OPTARG_Struct_unpack_BEGIN, 1) - 1;
+  size_t pos = (int)luaL_optinteger(L, WSLUA_OPTARG_Struct_unpack_BEGIN, 1) - 1;
   defaultoptions(&h);
   lua_settop(L, 2);
   while (*fmt) {
diff -Naur wireshark-2.0.0.orig/epan/wslua/wslua_tvb.c wireshark-2.0.0/epan/wslua/wslua_tvb.c
--- wireshark-2.0.0.orig/epan/wslua/wslua_tvb.c	2015-11-18 19:20:58.000000000 -0300
+++ wireshark-2.0.0/epan/wslua/wslua_tvb.c	2015-11-19 13:21:33.127407056 -0300
@@ -159,7 +159,7 @@
        offset is beyond the end of the `Tvb`. */
 #define Tvb_reported_length_remaining_OFFSET 2 /* offset */
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
+    int offset = (int) (int)luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
 
     lua_pushnumber(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
     WSLUA_RETURN(1); /* The captured length of the `Tvb`. */
@@ -174,8 +174,8 @@
 #define WSLUA_OPTARG_Tvb_bytes_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
     Tvb tvb = checkTvb(L,1);
     GByteArray* ba;
-    int offset = luaL_optint(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
-    int len = luaL_optint(L,WSLUA_OPTARG_Tvb_bytes_LENGTH,-1);
+    int offset = (int)luaL_optinteger(L, WSLUA_OPTARG_Tvb_bytes_OFFSET, 0);
+    int len = (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_bytes_LENGTH,-1);
 
     if (tvb->expired) {
         luaL_error(L,"expired tvb");
@@ -224,8 +224,8 @@
 #define WSLUA_OPTARG_Tvb_range_LENGTH 3 /* The length (in octets) of the range. Defaults to until the end of the `Tvb`. */
 
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
-    int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_LENGTH,-1);
+    int offset = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_OFFSET,0);
+    int len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_range_LENGTH,-1);
 
     if (push_TvbRange(L,tvb->ws_tvb,offset,len)) {
         WSLUA_RETURN(1); /* The TvbRange */
@@ -242,8 +242,8 @@
 #define WSLUA_OPTARG_Tvb_raw_OFFSET 2 /* The position of the first byte (default=0/first). */
 #define WSLUA_OPTARG_Tvb_raw_LENGTH 3 /* The length of the segment to get (default=all). */
     Tvb tvb = checkTvb(L,1);
-    int offset = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
-    int len = (int) luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
+    int offset = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_OFFSET,0);
+    int len = (int) (int)luaL_optinteger(L,WSLUA_OPTARG_Tvb_raw_LENGTH,-1);
 
     if (!tvb) return 0;
     if (tvb->expired) {
@@ -837,7 +837,7 @@
 #define WSLUA_OPTARG_TvbRange_nstime_ENCODING 2 /* An optional ENC_* encoding value to use */
     TvbRange tvbr = checkTvbRange(L,1);
     NSTime nstime;
-    const guint encoding = (guint) luaL_optinteger(L, WSLUA_OPTARG_TvbRange_nstime_ENCODING, 0);
+    const guint encoding = (guint) (int)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_nstime_ENCODING, 0);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
@@ -918,7 +918,7 @@
     /* Obtain a string from a `TvbRange`. */
 #define WSLUA_OPTARG_TvbRange_string_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_string_ENCODING, ENC_ASCII|ENC_NA);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
@@ -962,7 +962,7 @@
     /* Obtain a zero terminated string from a `TvbRange`. */
 #define WSLUA_OPTARG_TvbRange_stringz_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_stringz_ENCODING, ENC_ASCII|ENC_NA);
     gint offset;
     gunichar2 uchar;
 
@@ -1009,7 +1009,7 @@
          */
 #define WSLUA_OPTARG_TvbRange_strsize_ENCODING 2 /* The encoding to use. Defaults to ENC_ASCII. */
     TvbRange tvbr = checkTvbRange(L,1);
-    guint encoding = (guint)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
+    guint encoding = (lua_Unsigned)luaL_optinteger(L,WSLUA_OPTARG_TvbRange_strsize_ENCODING, ENC_ASCII|ENC_NA);
     gint offset;
     gunichar2 uchar;
 
@@ -1109,7 +1109,7 @@
 #define WSLUA_OPTARG_TvbRange_bytes_ENCODING 2 /* An optional ENC_* encoding value to use */
     TvbRange tvbr = checkTvbRange(L,1);
     GByteArray* ba;
-    const guint encoding = (guint)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_bytes_ENCODING, 0);
+    const guint encoding = (lua_Unsigned)luaL_optinteger(L, WSLUA_OPTARG_TvbRange_bytes_ENCODING, 0);
 
     if ( !(tvbr && tvbr->tvb)) return 0;
     if (tvbr->tvb->expired) {
